<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<%@ taglib uri="http://www.myfirefly.cn/tag/auth" prefix="auth"%>
<script type="text/javascript">
var spfTradeReturnVisitRecordDataGrid = $('#spfTradeReturnVisit-record-datagrid-json').datagrid({
	gridTitle : '回访记录',
    showToolbar: true,
    toolbarItem: '',
    addLocation: 'first',
    showLinenumber: false,
    filterThead: false,
    filterAll: true,
    sortAll : true,
    <auth:has funcId="spfTradeReturnVisit" action="/spfTradeReturnVisit/list.do">
    dataUrl: 'spfTradeReturnVisit/list.do?contractId=${contractId}',
    </auth:has>
    dataType: 'json',
    columns: [
        {
			name: '',
			label: '操作',
			align: 'center',
			width: 74,
			quicksort:false,
			menu: false,
			edit: false,
			render: function(value){
		        var html = '';
		        <auth:has funcId="spfTradeReturnVisit" action="/spfTradeReturnVisit/edit.do">
		    	html += '<div class="btn-group" role="group"><button type="button" class="btn btn-blue btn-sm" onclick="editSpfTradeReturnVisitRecord(this)"><i class="fa fa-edit"></i> 编辑</button></div>';
			    </auth:has>
		    	return html;
			}
        },
        {
            name: 'returnVisitPerson',
            label: '回访人',
            align: 'center',
            width: 120
        },
        {
            name: 'returnVisitDate',
            label: '回访日期',
            type : 'date',
            align: 'center',
            width: 120,
            render: function(val) {
            	if(val){
            		val = dateToStr('yyyy-MM-dd', new Date(val));
            	}
            	return val;
            }
        },
        {
            name: 'returnVisitContent',
            label: '办理进度',
            align: 'center',
            width: 300
        },
        {
            name: 'createBy',
            label: '创建人',
            align: 'center',
            width: 120
        },
        {
            name: 'createDate',
            label: '创建日期',
            type : 'date',
            pattern:'yyyy-MM-dd HH:mm:ss',
            align: 'center',
            width: 200,
            render: function(val) {
            	if(val){
            		val = dateToStr('yyyy-MM-dd HH:mm:ss', new Date(val));
            	}
            	return val;
            }
        }
    ],
    afterSave: function($trs, datas) {
        	this.refresh();
        },
    paging: {pageSize:20, selectPageSize:'20,30,40'},
    showTfoot: true,
    fullGrid: false,
    toolbarCustom: function(){
    	var html = '';
	    html += '<div class="btn-group" role="group"><button type="button" class="btn btn-green" onclick="refreshSpfTradeReturnVisitRecord()"><i class="fa fa-refresh"></i> 刷新</button></div>';
	    return html;
    }
});
try{
	spfTradeReturnVisitRecordDataGrid.data('bjui.datagrid').colLock(0, true);
} catch(e){}

function editSpfTradeReturnVisitRecord(_this) {
	var index = $(_this).closest("tr").index();
	var data = spfTradeReturnVisitRecordDataGrid.data('bjui.datagrid').getRowData(index);
	$('#edit-spfTradeReturnVisitRecord-dialog').dialog({
		id:'edit-spfTradeReturnVisitRecord-dialog',
		url:'spfTradeReturnVisit/edit.do',
		maxable: false,
		mask: true,
		width: 850,
		height: 350,
		onLoad: function($dialog){
			setEditSpfTradeReturnVisitRecordBtnEvent($dialog, true);
			
			var failCallback = function(result) {
				$dialog.alertmsg('info', result.message);
				$dialog.dialog('close', 'edit-spfTradeReturnVisitRecord-dialog');
			}
			getJsonData2Form('spfTradeReturnVisit/get.do', 'id='+data.id, $('#spfTradeReturnVisitRecord_form'), spfTradeReturnVisitRecordCallback, failCallback);
		},
		
		title:'回访管理 - 添加'});
}

function spfTradeReturnVisitRecordCallback($inputObj, _name, _val) {
	
}

function setEditSpfTradeReturnVisitRecordBtnEvent($dialog, isAdd) {
	var $save, $cancel;
	$save = $dialog.find('.save');
	$cancel = $dialog.find('.cancel');

	$save.click(function(){
		$('#spfTradeReturnVisitRecord_form').isValid(function(v) {
			if(v){
				var url = 'spfTradeReturnVisit/editSave.do';
				var data = $('#spfTradeReturnVisitRecord_form').serialize();
				var successCallBack = function(){
					$dialog.dialog('close', 'edit-spfTradeReturnVisitRecord-dialog');
					refreshSpfTradeReturnVisitRecord();
				}
				myAjax(url,	data, true,successCallBack,null);
			}
		});
	});

	$cancel.click(function(){
		$dialog.dialog('close', 'edit-spfTradeReturnVisitRecord-dialog');
	});
}

function refreshSpfTradeReturnVisitRecord(){
	spfTradeReturnVisitRecordDataGrid.datagrid("refresh");
}
</script>
<div class="bjui-pageContent">
<form action="" id="spfTradeReturnVisit_form" data-toggle="validate" data-alertmsg="false">
	<fieldset style="margin: 5px 0 0 5px;font-size: 14px;">
		<legend>回访记录</legend>
		<div style="padding:0px; height:300px; width:780px;">
	        <table id="spfTradeReturnVisit-record-datagrid-json" data-width="100%" data-height="100%" class="table table-bordered">
	        </table>
    	</div>
	</fieldset>
	<fieldset style="margin: 5px 0 0 5px;font-size: 14px;font-weight: bold;">
		<legend>回访信息栏</legend>
		<ul style='margin-top: 10px;margin-bottom: 10px;'>
	       	<li style='float:left;margin-bottom: 10px;'>
	       		<div style="width:350px;">
	       			<label for="l_returnVisitPerson" class="control-label x100">回访人：</label>
	       			<input type="text" name="returnVisitPerson" id="l_returnVisitPerson" value="${sessionScope.identity.userName}" readonly="readonly" data-rule="required;length[~50];jsvalide" size="20">
	       		</div>
	       	</li>
			<li style='float:left;margin-bottom: 10px;'>
	       		<div style="width:350px;">
	       			<label for="l_returnVisitDate" class="control-label x100">回访日期：</label>
	       			<input type="text" name="returnVisitDate" id="l_returnVisitDate" value="" readonly="readonly" data-toggle="datepicker" data-rule="required;length[~20];jsvalide" size="20">
	       		</div>
	       	</li>
	       	<li style='float:left;margin-bottom: 10px;'>
	       		<div style="width:700px;">
	       			<label for="l_returnVisitContent" class="control-label x100">办理进度：</label>
	       			<textarea name="returnVisitContent" id="l_returnVisitContent" rows="5" cols="55" data-rule="required;length[~200];jsvalide"></textarea>
	       		</div>
	       	</li>
	    </ul>
	</fieldset>
	<fieldset style="margin: 5px 0 0 5px;font-size: 14px;font-weight: bold;">
		<legend>客户所购信息</legend>
		<ul style='margin-top: 10px;margin-bottom: 10px;'>
			<li style='float:left;margin-bottom: 10px;'>
	       		<div style="width:350px;">
	       			<label for="l_tradeContractId" class="control-label x100">成交地址：</label>
	       			<input type="hidden" id="i_tradeContractId" name="tradeContractId">
	       			<input type="text" name="tradeAddress" id="l_tradeAddress" readonly="readonly" 
	       				data-rule="required;length[~50];jsvalide" class="doc_lookup" size="20">
	       		</div>
	       	</li>
	       	<li style='float:left;margin-bottom: 10px;'>
	       		<div style="width:350px;">
	       			<label for="l_customerName" class="control-label x100">客户姓名：</label>
	       			<input type="text" name="customerName" id="l_customerName" value="" readonly="readonly" size="20">
	       		</div>
	       	</li>
	       	<li style='float:left;margin-bottom: 10px;'>
	       		<div style="width:350px;">
	       			<label for="l_identifyNum" class="control-label x100">证件号码：</label>
	       			<input type="text" name="identifyNum" id="l_identifyNum" value="" readonly="readonly" size="20">
	       		</div>
	       	</li>
	       	<li style='float:left;margin-bottom: 10px;'>
	       		<div style="width:350px;">
	       			<label for="l_contactWay" class="control-label x100">联系方式：</label>
	       			<input type="text" name="contactWay" id="l_contactWay" value="" readonly="readonly" size="20">
	       		</div>
	       	</li>
	       	<li style='float:left;margin-bottom: 10px;'>
	       		<div style="width:350px;">
	       			<label for="l_tradeDate" class="control-label x100">成交日期：</label>
	       			<input type="text" name="tradeDate" id="l_tradeDate" value="" size="20" readonly="readonly">
	       		</div>
	       	</li>
	       	<li style='float:left;margin-bottom: 10px;'>
	       		<div style="width:350px;">
	       			<label for="l_receivableCommission" class="control-label x100">应收佣金：</label>
	       			<input type="text" name="receivableCommission" id="l_receivableCommission" readonly="readonly" size="20">
	       		</div>
	       	</li>
	    </ul>
	</fieldset>
	<fieldset style="margin: 5px 0 0 5px;font-size: 14px;font-weight: bold;">
		<legend>成交人基本信息</legend>
		<ul style='margin-top: 10px;margin-bottom: 10px;'>
	       	<li style='float:left;margin-bottom: 10px;'>
	       		<div style="width:350px;">
	       			<label for="l_tradeRegion" class="control-label x100">成交区域：</label>
	       			<input type="text" name="tradeRegion" id="l_tradeRegion" value="" readonly="readonly" size="20">
	       		</div>
	       	</li>
	       	<li style='float:left;margin-bottom: 10px;'>
	       		<div style="width:350px;">
	       			<label for="l_tradeShop" class="control-label x100">成交店面：</label>
	       			<input type="text" name="tradeShop" id="l_tradeShop" value="" readonly="readonly" size="20">
	       		</div>
	       	</li>
	       	<li style='float:left;margin-bottom: 10px;'>
	       		<div style="width:350px;">
	       			<label for="l_tradePerson" class="control-label x100">成交人：</label>
	       			<input type="text" name="tradePerson" id="l_tradePerson" value="" readonly="readonly" size="20">
	       		</div>
	       	</li>
	       	<li style='float:left;margin-bottom: 10px;'>
	       		<div style="width:350px;">
	       			<label for="l_belongShopManager" class="control-label x100">所属店经理：</label>
	       			<input type="text" name="belongShopManager" id="l_belongShopManager" value="" readonly="readonly" size="20">
	       		</div>
	       	</li>
		</ul>
	</fieldset>
	<fieldset style="margin: 5px 0 0 5px;font-size: 14px;font-weight: bold;">
		<legend>成交跟踪单信息</legend>
		<ul style='margin-top: 10px;margin-bottom: 10px;'>
			<li style='float:left;margin-bottom: 10px;'>
	       		<div style="width:350px;">
	       			<label for="l_hasAptitude" class="control-label x100">有无资质：</label>
	       			<select id="l_hasAptitude" name="hasAptitude" data-toggle="selectpicker" data-width="200" disabled="disabled">
						<option value="1">有</option>
						<option value="0">无</option>
		       		</select>
	       		</div>
	       	</li>
	       	<li style='float:left;margin-bottom: 10px;'>
	       		<div style="width:350px;visibility: hidden">
	       			<label for="l_hasAptitude" class="control-label x100">：</label>
	       			<input size="20">
	       		</div>
	       	</li>
			<li id="aptitudeHandleType1" style='float:left;margin-bottom: 10px;'>
	       		<div style="width:350px;">
	       			<label for="l_aptitudeHandleType" class="control-label x100">资质办理方式：</label>
	       			<select id="l_aptitudeHandleType" name="aptitudeHandleType" data-toggle="selectpicker" data-width="200" disabled="disabled">
						<option value="GS">公司办理资质</option>
						<option value="ZX">自行办理资质</option>
						<option value="SF">三方办理资质</option>
						<option value="QT">其他</option>
		       		</select>
	       		</div>
	       	</li>
	       	<li id="aptitudeHandleType2" style='float:left;margin-bottom: 10px;'>
	       		<div style="width:350px;">
	       			<label for="l_aptitudeHandleTypeRemark" class="control-label x100">详情：</label>
	       			<input type="text" name="aptitudeHandleTypeRemark" id="l_aptitudeHandleTypeRemark" readonly="readonly" data-rule="length[~50];jsvalide" size="20">
	       		</div>
	       	</li>
			<li style='float:left;margin-bottom: 10px;'>
	       		<div style="width:350px;">
	       			<label for="l_buyType" class="control-label x100">认购方式：</label>
	       			<select id="l_buyType" name="buyType" data-toggle="selectpicker" data-width="200" disabled="disabled">
						<option value="QK">全款</option>
						<option value="DK">贷款</option>
						<option value="FQ">分期</option>
		       		</select>
	       		</div>
	       	</li>
	       	<li style='float:left;margin-bottom: 10px;'>
	       		<div style="width:350px;">
	       			<label for="l_buyTypeRemark" class="control-label x100">详情：</label>
	       			<input type="text" name="buyTypeRemark" id="l_buyTypeRemark" readonly="readonly" data-rule="length[~50];jsvalide" size="20">
	       		</div>
	       	</li>
			<li style='float:left;margin-bottom: 10px;'>
	       		<div style="width:350px;">
	       			<label for="l_firstPayDate" class="control-label x100">交首付日期：</label>
	       			<input type="text" name="firstPayDate" id="l_firstPayDate" value="" readonly="readonly" data-rule="length[~20];jsvalide" size="20">
	       		</div>
	       	</li>
	       	<li style='float:left;margin-bottom: 10px;'>
	       		<div style="width:350px;">
	       			<label for="l_residentContact" class="control-label x100">驻场联络人：</label>
	       			<input type="text" name="residentContact" id="l_residentContact" readonly="readonly" data-rule="length[~50];jsvalide" size="20">
	       		</div>
	       	</li>
	    </ul>
	</fieldset>
	<fieldset style="margin: 5px 0 0 5px;font-size: 14px;font-weight: bold;">
		<legend>老带新信息</legend>
		<ul style='margin-top: 10px;margin-bottom: 10px;'>
			<li style='float:left;margin-bottom: 10px;'>
	       		<div style="width:350px;">
	       			<label for="l_oldBeltNew" class="control-label x100">是否老带新：</label>
	       			<select id="l_oldBeltNew" name="oldBeltNew" data-toggle="selectpicker" data-width="200" disabled="disabled">
						<option value="1">是</option>
						<option value="0">否</option>
		       		</select>
	       		</div>
	       	</li>
	       	<li style='float:left;margin-bottom: 10px;'>
	       		<div style="width:350px;">
	       			<label for="l_oldCustomerName" class="control-label x100">老客户姓名：</label>
	       			<input type="text" name="oldCustomerName" id="l_oldCustomerName" readonly="readonly" data-rule="length[~50];jsvalide" size="20">
	       		</div>
	       	</li>
	       	<li style='float:left;margin-bottom: 10px;'>
	       		<div style="width:350px;">
	       			<label for="l_oldCustomerIds" class="control-label x100">身份证号：</label>
	       			<input type="text" name="oldCustomerIds" id="l_oldCustomerIds" readonly="readonly" data-rule="length[~50];jsvalide" size="20">
	       		</div>
	       	</li>
	       	<li style='float:left;margin-bottom: 10px;'>
	       		<div style="width:350px;">
	       			<label for="l_oldCustomerContact" class="control-label x100">联系电话：</label>
	       			<input type="text" name="oldCustomerContact" id="l_oldCustomerContact" readonly="readonly" data-rule="length[~50];jsvalide" size="20">
	       		</div>
	       	</li>
	       	<li style='float:left;margin-bottom: 10px;'>
	       		<div style="width:350px;">
	       			<label for="l_oldCustomerBuyAddress" class="control-label x100" style="font-size: 12px;">老客户所购房号：</label>
	       			<input type="text" name="oldCustomerBuyAddress" id="l_oldCustomerBuyAddress" readonly="readonly" data-rule="length[~50];jsvalide" size="20">
	       		</div>
	       	</li>
	    </ul>
	</fieldset>
	<fieldset style="margin: 5px 0 0 5px;font-size: 14px;font-weight: bold;">
		<legend>备注信息栏</legend>
		<ul>
			<li style='float:left;margin-bottom: 10px;'>
	       		<div style="width:700px;">
	       			<label for="l_remark" class="control-label x100">备注：</label>
	       			<textarea name="remark" id="l_remark" rows="5" cols="55" readonly="readonly" data-rule="length[~100];jsvalide"></textarea>
	       		</div>
	       	</li>
	    </ul>
	</fieldset>
	
</form>
</div>
<div class="bjui-pageFooter">
	<ul>
		<li><button type="button" class="btn btn-red cancel" data-icon="remove">取消</button></li>
		<auth:has funcId="spfTradeReturnVisit" action="/spfTradeReturnVisit/addSave.do">
		<li><button type="button" class="btn btn-default save" data-icon="save">保存</button></li>
		</auth:has>
	</ul>
</div>
<div id="edit-spfTradeReturnVisitRecord-dialog" style="display: none;">
</div>